# -*- coding: utf-8 -*-
from django.conf.urls.defaults import *
from django.shortcuts import get_object_or_404
from models import Poll, Screenshot, Release, Video
import views

urlpatterns = patterns("",
    
    (r'^$', views.overview),
    (r'^latest/$', views.overview, {"order_by":"-last_edited"}), 
    (r'^discussed/$', views.overview, {"order_by":"-comment_count"}), 
    (r'^alphabet/$', views.overview, {"order_by":"name"}), 
    (r'^tags/$', views.overview, {"order_by":"tag"}), 
    url(r'^tags/(?P<tag>[^/]+)/$', views.overview, {"order_by":"tag"},
                                    name="project_tag_page"), 
    (r'^random/$', views.random),
    (r'^create/$', views.create_or_edit_project),    
    url(r'^project-of-the-month/$', 'django.views.generic.list_detail.object_list',
                       {"queryset":Poll.objects.filter(active=False),
                        "template_name":"projects/poll_overview.html",
                        "template_object_name":"poll"},
                        name="potm-overview"),
    url(r'^project-of-the-month/(?P<month>\w{1,2})/(?P<year>\d{4})/$', 
                        views.detail_poll,
                        name="view_poll"),
    url(r'^(?P<project_slug>[\w-]+)/edit/$', views.create_or_edit_project,
                        name="edit_project"),
    url(r'^(?P<project_slug>[\w-]+)/add_release/$', 
                        views.create_or_edit_release,
                        name="add_release"),
    url(r'^(?P<project_slug>[\w-]+)/screenshots/add/$',
                        views.create_or_edit_screenshot, 
                        name="add_screenshot"),
    url(r'^(?P<project_slug>[\w-]+)/screenshots/(?P<screenshot_slug>[\w-]+)/$', 
                        views.detail_screenshot,
                        name="view_screenshot"),
    url(r'^(?P<project_slug>[\w-]+)/screenshots/(?P<screenshot_slug>[\w-]+)/edit/$', 
                        views.create_or_edit_screenshot,
                        name="edit_screenshot"),
    url(r'^(?P<project_slug>[\w-]+)/screenshots/(?P<slug>[\w-]+)/delete/$',
                        views.generic_delete_wrapper, 
                        {"model":Screenshot, "slug_field":"slug"},
                        name="delete_screenshot"),

    url(r'^(?P<project_slug>[\w-]+)/videos/add/$',
                        views.create_or_edit_video, 
                        name="add_video"),
    url(r'^(?P<project_slug>[\w-]+)/videos/(?P<video_slug>[\w-]+)/$', 
                        views.detail_video,
                        name="view_video"),
    url(r'^(?P<project_slug>[\w-]+)/videos/(?P<video_slug>[\w-]+)/edit/$', 
                        views.create_or_edit_video,
                        name="edit_video"),
    url(r'^(?P<project_slug>[\w-]+)/videos/(?P<slug>[\w-]+)/delete/$',
                        views.generic_delete_wrapper, 
                        {"model":Video, "slug_field":"slug"},
                        name="delete_video"),
                        
                                                
    url(r'^(?P<project_slug>[\w-]+)/(?P<release_slug>[\w-]+)/edit/$', 
                        views.create_or_edit_release,
                        name="edit_release"),
    url(r'^(?P<project_slug>[\w-]+)/(?P<slug>[\w-]+)/delete/$', 
                        views.generic_delete_wrapper, 
                        {"model":Release, "slug_field":"slug"},
                        name="delete_release"),                        
    url(r'^(?P<project_slug>[\w-]+)/(?P<release_slug>[\w-]+)/$', views.detail,
                        name="view_release"),
    url(r'^(?P<project_slug>[\w-]+)/$', views.detail, name="view_project"),
    
    
) 
